package fti.uksw.ruang.model;

import java.util.Date;

import android.os.Parcel;
import android.os.Parcelable;

public class Login implements Parcelable {
	public final static String TAG = "login";
	public final static String TABLEBNAME = "tblogin";
	public final static String ID = "id";
	public final static String USERNAME = "username";
	public final static String PASSWORD = "password";
	public final static String LASTLOGIN = "last_login";
	public final static String IDUSER = "id_user";

	private int id;
	private String username;
	private String password;
	private Date lastLogin;
	private int idUser;

	public Login() {
	}

	public Login(Parcel in) {
		readFromParcel(in);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getIdUser() {
		return idUser;
	}

	public void setIdUser(int idUser) {
		this.idUser = idUser;
	}

	public Date getLastLogin() {
		return lastLogin;
	}

	public void setLastLogin(Date lastLogin) {
		this.lastLogin = lastLogin;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(username);
		dest.writeString(password);
		dest.writeLong(lastLogin.getTime());
		dest.writeInt(idUser);
	}

	private void readFromParcel(Parcel in) {
		id = in.readInt();
		username = in.readString();
		password = in.readString();
		lastLogin = new Date(in.readLong());
		idUser = in.readInt();
	}

	public static final Parcelable.Creator<Login> CREATOR = new Parcelable.Creator<Login>() {

		@Override
		public Login createFromParcel(Parcel source) {
			return new Login(source);
		}

		@Override
		public Login[] newArray(int size) {
			return new Login[size];
		}
	};

}
